#ifndef __GAME_MANAGER__
#define __GAME_MANAGER__

#include "Header.h"
#include "InputData.h"

#define TRIAL_MODE 0
#define GAME_VERSION 8
#define TIME_NOT_UPDATE 1.0f

#define kGameTimeIncreaseNotification "kGameTimeIncreaseNotification"

class Road;
class GamePlayLayer;

class GameManager : public CCNode
{
public:
	static GameManager* getInstance();
	~GameManager();
    
	float vBusMax;
	float vCarMax;
	float vMotoMax;

	float roadLength;
	float laneWidth;

	float motoWidth;
	float motoLength;
	float carWidth;
	float carLength;
	float busWidth;
	float busLength;

//	float addBusTime;
//	float addCarTime;
//	float addMotoTime;

	float safeDistanceAhead;    // not use
	float safeDistanceBeside;

	float greenLightTime;
	float redLightTime;

	int busLaneMode;

	bool isUseable;
	int preventCarTurnLaneBeforeCrossRoadDistance;
//	int sessionDuration;
	bool isShowingAlert;
    GamePlayLayer* gamePlayLayer;
    
    // save lane info
    int numBusLane1;
    int numMotoLane1;
    int numCarLane1;
    int numMotoLane2;
    int numCarLane2;
    int numMotoLane3;
    int numCarLane3;
    void saveLaneInfo();
    
    InputData* inputData;

	// save vehicle summary
	CCDictionary* vehicleInfoDictionary;
	int getCurrentVehicleId();
	void resetGame();

	// save vehicle info
	char currentSessionTimeString[32];
	FILE* vehicleInfoFile;
	CCTimer* oneSecondTimer;
	Road* road;
	void beginNewSession();
	void endSaveSession();
	void saveVehicleInfo();
    int getGameTime();
    void increaseGameTime();
	
private:
    int gameTime;
    
	GameManager();
	static GameManager* instance;
	int currentVehicleId;
	CREATE_FUNC(GameManager);
	bool init();
	void oneSecondTick(float t);
	void update(float delta);
};

#endif // !__GAME_MANAGER__
